package com.jianneng.jdg.model.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.com.jianneng.jdg.R;
import com.jianneng.jdg.model.adapter.DetailAdapter.ViewHolder1;
import com.jianneng.jdg.model.user.ReleaseInfo;

public class SquareListAdapter extends BaseAdapter {
	private List<ReleaseInfo> list = new ArrayList<ReleaseInfo>();
	private Context context;
	private LayoutInflater mInflater;

	public SquareListAdapter(List<ReleaseInfo> list, Context context) {
		super();
		this.list = list;
		this.context = context;
		mInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder mHolder = null;
		if (convertView == null) {
			mHolder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.release_activities, null);
			mHolder.detail_item_userimage = (ImageView) convertView
					.findViewById(R.id.detail_item_userimage);
			mHolder.detail_item_username = (TextView) convertView
					.findViewById(R.id.detail_item_username);
			mHolder.detail_item_comment = (ImageView) convertView
					.findViewById(R.id.detail_item_comment);
			convertView.setTag(mHolder);
			mHolder.detail_item_comment
					.setOnClickListener(new OnClickListener() {
						@Override
						public void onClick(View v) {
							Toast.makeText(context, "评论", 1).show();
						}
					});
		} else {
			mHolder = (ViewHolder) convertView.getTag();
		}
		// 设置资源
		ReleaseInfo info = list.get(position);
		return convertView;
	}

	public class ViewHolder {
		ImageView detail_item_userimage;
		TextView detail_item_username;
		ImageView detail_item_comment;

	}

}
